using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

namespace NetworkTimer
{
    [Serializable()]
    public class MySetting : ISerializable
    {
        //Variable for Bridge Settings
        private DateTime _BdgStartTime;
        private DateTime _BdgStopTime;
        private bool _BdgEnable;
        private bool _BdgShdwn;


        //Variable for PPPoE
        private DateTime _PPPoEStartTime;
        private DateTime _PPPoEStopTime;
        private bool _PPPoEEnable;
        private bool _PPPoEShdwn;

        //Varible for Load Application Settings
        private bool _AppEnable;
        private string _AppPath;

        public MySetting()
        {
            _BdgEnable = false;
            _BdgShdwn = false;

            _AppEnable = false;
            _AppPath = "";
        }

        //settings for Bridge
        public DateTime BridgeStartTime
        {
            get
            {
                return _BdgStartTime;

            }
            set
            {
                _BdgStartTime = value;
            }
        }

        public DateTime BridgeStopTime
        {
            get
            {
                return _BdgStopTime;

            }
            set
            {
                _BdgStopTime = value;
            }
        }

        public bool BridgeStopEnable
        {
            get
            {
                return _BdgEnable;

            }
            set
            {
                _BdgEnable = value;
            }
        }

        public bool BridgeShutdown
        {
            get
            {
                return _BdgShdwn;

            }
            set
            {
                _BdgShdwn = value;
            }
        }


        //settings for PPPoE
        public DateTime PPPoEStartTime
        {
            get
            {
                return _PPPoEStartTime;

            }
            set
            {
                _PPPoEStartTime = value;
            }
        }

        public DateTime PPPoEStopTime
        {
            get
            {
                return _PPPoEStopTime;

            }
            set
            {
                _PPPoEStopTime = value;
            }
        }

        public bool PPPoEStopEnable
        {
            get
            {
                return _PPPoEEnable;

            }
            set
            {
                _PPPoEEnable = value;
            }
        }

        public bool PPPoEShutdown
        {
            get
            {
                return _PPPoEShdwn;

            }
            set
            {
                _PPPoEShdwn = value;
            }
        }

        // Load Appliction Settings
        public bool AppEnable
        {
            get
            {
                return _AppEnable;

            }
            set
            {
                _AppEnable = value;
            }
        }
        public string AppPath
        {
            get
            {
                return _AppPath;

            }
            set
            {
                _AppPath = value;
            }
        }


        public MySetting(SerializationInfo info, StreamingContext ctxt)
        {
            //Get the values from info and assign them to the appropriate properties

            //for Bridge
            _BdgStartTime = (DateTime)info.GetValue("BridgeStartTime", typeof(DateTime));
            _BdgStopTime = (DateTime)info.GetValue("BridgeStopTime", typeof(DateTime));
            _BdgEnable = (bool)info.GetValue("BridgeStopEnable", typeof(bool));
            _BdgShdwn = (bool)info.GetValue("BridgeShutdown", typeof(bool));

            //for PPPoE
            _PPPoEStartTime = (DateTime)info.GetValue("PPPoEStartTime", typeof(DateTime));
            _PPPoEStopTime = (DateTime)info.GetValue("PPPoEStopTime", typeof(DateTime));
            _PPPoEEnable = (bool)info.GetValue("PPPoEStopEnable", typeof(bool));
            _PPPoEShdwn = (bool)info.GetValue("PPPoEShutdown", typeof(bool));


            _AppEnable = (bool)info.GetValue("AppEnable", typeof(bool));
            _AppPath = (string)info.GetValue("AppPath", typeof(string));

        }

        //Serialization function.
        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            //You can use any custom name for your name-value pair. But make sure you

            // read the values with the same name. For ex:- If you write EmpId as "EmployeeId"

            // then you should read the same with "EmployeeId"

            //for Bridge
            info.AddValue("BridgeStartTime", _BdgStartTime);
            info.AddValue("BridgeStopTime", _BdgStopTime);
            info.AddValue("BridgeStopEnable", _BdgEnable);
            info.AddValue("BridgeShutdown", _BdgShdwn);

            //for PPPoE
            info.AddValue("PPPoEStartTime", _PPPoEStartTime);
            info.AddValue("PPPoEStopTime", _PPPoEStopTime);
            info.AddValue("PPPoEStopEnable", _PPPoEEnable);
            info.AddValue("PPPoEShutdown", _PPPoEShdwn);

            //for Application
            info.AddValue("AppEnable", _AppEnable);
            info.AddValue("AppPath", _AppPath);

        }

    }
}
